package com.crazymaker.springcloud.message.dao;

import com.crazymaker.springcloud.message.dao.po.MsgStreamPO;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by 尼恩 on 2019/7/18.
 */
@Repository
public interface MsgStreamDao extends JpaRepository<MsgStreamPO, Long>, JpaSpecificationExecutor<MsgStreamPO> {
    /**
     * 根据  查询 发送消息的历史信息
     * @param appkey    推送的key
     * @param targetId  渠道账号
     * @param pageable
     * @return
     */
    Page<MsgStreamPO> findByAppKeyAndTargetId(String appkey, String targetId, Pageable pageable);
    List<MsgStreamPO> findByMsgId(Long msgId);


    @Modifying
    @Query("update MsgStreamPO m set m.sendStatus=?1 where  m.streamId=?2")
    void updateStatusByStreamId(int status, Long streamId);
}
